@extends('user.layouts.layout')
@section('title', '订单列表')

@section('content')
    <div class="flex flex-col mt-6">
        <div class="-my-2 py-2 overflow-x-auto sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8">
            <div class="align-middle inline-block min-w-full shadow overflow-hidden sm:rounded-lg border-b border-gray-200">
                <table class="min-w-full">
                    <thead>
                    <tr>
                        <th class="px-6 py-3 border-b border-gray-200 bg-gray-100 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap ">
                            ID
                        </th>
                        <th class="px-6 py-3 border-b border-gray-200 bg-gray-100 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap ">
                            商户
                        </th>
                        <th class="px-6 py-3 border-b border-gray-200 bg-gray-100 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap ">
                            金额
                        </th>
                        <th class="px-6 py-3 border-b border-gray-200 bg-gray-100 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap ">
                            发生时间
                        </th>
                        <th class="px-6 py-3 border-b border-gray-200 bg-gray-100 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap ">
                            操作人
                        </th>
                        <th class="px-6 py-3 border-b border-gray-200 bg-gray-100 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap ">
                            备注
                        </th>
                    </tr>
                    </thead>
                    <tbody class="bg-white">
                    @foreach($logs as $log)
{{--                        'user_id', 'merchant_id', 'change_type', 'amount', 'operator', 'remark'--}}
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap border-b border-gray-200">
                                <span>{{ $log->id }}</span>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap border-b border-gray-200">
                                <span>{{ $log->merchant_id }}</span>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap border-b border-gray-200">
                                @if($log->change_type === \App\Models\BalanceLog::CHANGE_TYPE_INC)
                                    <span class="text-red-500">+ {{ $log->amount }}</span>
                                @elseif($log->change_type === \App\Models\BalanceLog::CHANGE_TYPE_DEC)
                                    <span class="text-green-500">- {{ $log->amount }}</span>
                                @endif

                            </td>
                            <td class="px-6 py-4 whitespace-nowrap border-b border-gray-200">
                                <span>{{ $log->created_at }}</span>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap border-b border-gray-200">
                                <span>{{ $log->operator === 'system' ? '系统' : $log->operator }}</span>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap border-b border-gray-200">
                                <span>{{ $log->remark }}</span>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="mt-6">
        {{ $logs->links('components.paginator') }}
    </div>
@endsection
